# -*- coding:utf-8 -*-

import yaml
from yaml.scanner import ScannerError


def get_yaml(path):
    try:
        with open(path, encoding='utf-8') as f:
            x = yaml.load(f, Loader=yaml.FullLoader)
            return x
    except FileNotFoundError:
        msg = "找不到用例文件"
        tab = "==" * len(msg)
        print(tab, "\n", msg, "\n", tab)

        return False
    except yaml.scanner.ScannerError:
        msg = "用例格式错误"
        tab = "==" * len(msg)
        print(tab, "\n", msg, "\n", tab)

        return False


if __name__ == '__main__':
    print(get_yaml("../Yaml/test.yaml").get("check")[0])
    a = get_yaml("../Yaml/test.yaml")
